



// let axios = require("axios");
let fs = require("fs")


// axios.default.get("http://www.teandy.com/pal/").then(res => {
//     fs.writeFileSync("./ty.html", res.data)
// });



// <tr>
//     <td>001-棉悠悠</td>
//     <td title="它只要走在坡道上就肯定会跌倒并滚动起来。而且还会因为眼冒金星而无法动弹，非常容易被当做是猎物，是食物链的底层。"><img src="img/001.jpg"></td>
//     <td><span style="color:#b19087;"><b>[无]</b></span></td>
//     <td title="发动后，它会化身为装备在玩家身上的盾牌。将它分派到家畜牧场，它就有机会掉落羊毛。">茸茸盾牌</td>
//     <td>做盾</td>
//     <td>手工1<br>搬运1<br>牧场1</td>
//     <td>2</td>
//     <td>白天</td>
//     <td>羊毛<br>棉悠悠的羊肉</td>
// </tr>




let str = fs.readFileSync("./ty.html").toString()


let match = str.match(/<tr>(?:(?!<\/tr>)[\w\W])+<\/tr>/g)

let rets = match.map(table => {
    let td = table.match(/<td(?:(?!<\/td>)[\w\W])+<\/td>/g);
    let ret = {}
    if(/<td>(.+)<\/td>/.test(td[0])){
        ret.name = RegExp.$1;
    }
    if(/<td>(.+)<\/td>/.test(td[6])){
        ret.eat = RegExp.$1;
    }
    if(/<td>(.+)<\/td>/.test(td[7])){
        ret.time = RegExp.$1;
    }
    if(/<td title="([^"]+)">(.+)<\/td>/.test(td[1])){
        ret.title = RegExp.$1;
    }
    if(/<b>(.+)<\/b>/.test(td[2])){
        ret.prop = RegExp.$1.match(/\[[^\]]+\]/g).map(v => /^\[(.+)\]$/.exec(v)[1]);
    }
    if(/<td title="([^"]+)">(.+)<\/td>/.test(td[3])){
        ret.skillTitle = RegExp.$1;
        ret.skillName = RegExp.$2;
    }

    if(/<td>(.+)<\/td>/.test(td[4])){
        ret.des = RegExp.$1;
    }
    if(/<td>(.+)<\/td>/.test(td[5])){
        ret.work = RegExp.$1.split("<br>");
    }
    if(/<td>(.+)<\/td>/.test(td[8])){
        ret.items = RegExp.$1.split("<br>");
    }
    return ret
});

fs.writeFileSync("./plsDatas.js", "module.exports = " + JSON.stringify(rets))


